<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Northwinddemo.Master" Inherits="System.Web.Mvc.ViewPage<ProductViewModel>" %>
<%@ Import Namespace="Northwinddemo.DAL.EntityClasses"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%= Model.Product.ProductId != 0 ? "Edit" : "Create" %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2><%= Model.Product.ProductId != 0 ? "Edit" : "Create"%> product</h2>
    <%= Html.ValidationSummary("Unsuccessful. Please correct the errors and try again.") %>
    <%= Html.ClientSideValidation<ProductsEntity>(ExpressHelper.GetPropertyName<ProductViewModel>(p => p.Product))%>
    
    <% using (Html.BeginForm()) {%>

        <fieldset>
            <legend>Fields</legend>
            <%= Html.EditorFor(p => p) %>
            <p>
                <input type="submit" value="Save" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <% if (Model.Product.ProductId != 0)
           { %>
           <%= Html.ActionLink<ProductsController>(p => p.Details(Model.Product.ProductId), "Back to Details")%>
        <% } 
           else
           { %>
           <%= Html.ActionLink<ProductsController>(p => p.Index(null, null), "Back to List")%>
        <% } %>
        
    </div>

</asp:Content>
